using System;
using System.Threading.Tasks;
using SheLife.Domain.Entities;

namespace SheLife.Domain.Interfaces.Repositories
{
    /// <summary>
    /// 系统字典仓储接口
    /// </summary>
    public interface ISystemDictRepository : IRepository<SystemDictionary>
    {
        /// <summary>
        /// 根据字典类型获取字典列表
        /// </summary>
        /// <param name="type">字典类型</param>
        /// <returns>字典列表</returns>
        Task<IEnumerable<SystemDictionary>> GetByTypeAsync(string type);

        /// <summary>
        /// 根据字典类型和字典值获取字典
        /// </summary>
        /// <param name="type">字典类型</param>
        /// <param name="value">字典值</param>
        /// <returns>字典</returns>
        Task<SystemDictionary> GetByTypeAndValueAsync(string type, string value);

        /// <summary>
        /// 根据字典类型和字典标签获取字典
        /// </summary>
        /// <param name="type">字典类型</param>
        /// <param name="label">字典标签</param>
        /// <returns>字典</returns>
        Task<SystemDictionary> GetByTypeAndLabelAsync(string type, string label);

        /// <summary>
        /// 检查字典类型是否存在
        /// </summary>
        /// <param name="type">字典类型</param>
        /// <returns>是否存在</returns>
        Task<bool> CheckDictTypeExistsAsync(string type);

        /// <summary>
        /// 检查字典值是否存在
        /// </summary>
        /// <param name="type">字典类型</param>
        /// <param name="value">字典值</param>
        /// <returns>是否存在</returns>
        Task<bool> CheckDictValueExistsAsync(string type, string value);

        /// <summary>
        /// 获取字典标签
        /// </summary>
        /// <param name="type">字典类型</param>
        /// <param name="value">字典值</param>
        /// <returns>字典标签</returns>
        Task<string> GetDictLabelAsync(string type, string value);

        /// <summary>
        /// 获取字典标签（带默认值）
        /// </summary>
        /// <param name="type">字典类型</param>
        /// <param name="value">字典值</param>
        /// <param name="defaultValue">默认值</param>
        /// <returns>字典标签</returns>
        Task<string> GetDictLabelAsync(string type, string value, string defaultValue);

        /// <summary>
        /// 获取字典值
        /// </summary>
        /// <param name="type">字典类型</param>
        /// <param name="label">字典标签</param>
        /// <returns>字典值</returns>
        Task<string> GetDictValueAsync(string type, string label);

        /// <summary>
        /// 获取字典值（带默认值）
        /// </summary>
        /// <param name="type">字典类型</param>
        /// <param name="label">字典标签</param>
        /// <param name="defaultValue">默认值</param>
        /// <returns>字典值</returns>
        Task<string> GetDictValueAsync(string type, string label, string defaultValue);

        /// <summary>
        /// 获取字典列表（分页）
        /// </summary>
        /// <param name="pageIndex">页索引</param>
        /// <param name="pageSize">页大小</param>
        /// <param name="type">字典类型</param>
        /// <param name="keyword">关键词</param>
        /// <returns>字典列表</returns>
        Task<(IEnumerable<SystemDictionary> Items, int TotalCount)> GetDictsPagedAsync(int pageIndex, int pageSize, string type = null, string keyword = null);

        /// <summary>
        /// 启用字典
        /// </summary>
        /// <param name="dictId">字典ID</param>
        /// <param name="operatorId">操作人ID</param>
        /// <returns>是否成功</returns>
        Task<bool> EnableDictAsync(Guid dictId, Guid operatorId);

        /// <summary>
        /// 禁用字典
        /// </summary>
        /// <param name="dictId">字典ID</param>
        /// <param name="operatorId">操作人ID</param>
        /// <returns>是否成功</returns>
        Task<bool> DisableDictAsync(Guid dictId, Guid operatorId);

        /// <summary>
        /// 刷新字典缓存
        /// </summary>
        /// <returns>是否成功</returns>
        Task<bool> RefreshDictCacheAsync();
    }
}